﻿using BoriPeter.FatSecret.Converters;
using BoriPeter.FatSecret.Messages;
using BoriPeter.FitnessJournal8.Models;
using BoriPeter.FitnessJournal8.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BoriPeter.FatSecret
{
    public class FatSecretWeightDataSource
    {
        public async Task<List<DailyEntry>> GetMonthListAsync(DateTime _dayOfMonth)
        {
            if (FatSecretCommon.AccessToken != null)
            {
                var weightsGetMonth = new WeightsGetMonth(_dayOfMonth);
                var weightList = await weightsGetMonth.SendAsync();
                return weightList.Convert();
            }
            else
                return new List<DailyEntry>();
        }

        public Task<DailyEntry> GetDailyEntryAsync(DateTime _date)
        {
            throw new NotImplementedException();
        }

        public async Task SaveAsync(DailyEntry _entry)
        {
            if (FatSecretCommon.AccessToken != null)
            {
                var weightAdd = new WeightUpdate(_entry.WeightKg, _entry.Date);
                var weightList = await weightAdd.SendAsync();
            }
        }
    }
}
